-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Port RE2 regex tests to improve test coverage #120845
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Co-authored-by: stephentoub <[email protected]>
Co-authored-by: stephentoub <[email protected]>
Copilot
AI
changed the title
[WIP] Port re2 regex tests to improve coverage
Port RE2 regex tests to improve test coverage
Oct 17, 2025
Copilot finished work on behalf of
stephentoub
October 17, 2025 14:10
Contributor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Ports a subset of RE2's functional regex tests into the .NET test suite to expand coverage across multiple regex engines.
- Adds 142 test cases derived from RE2's re2_test.cc and search_test.cc.
- Updates test project file to include the new test file and adds RE2's BSD 3-Clause license to third-party notices.
- Exercises diverse regex features (anchors, word boundaries, quantifiers, escapes, Unicode) across all available engines.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| THIRD-PARTY-NOTICES.TXT | Adds RE2 BSD 3-Clause license attribution for the ported tests. |
| System.Text.RegularExpressions.Tests.csproj | Includes the new RegexRe2Tests.cs file in the test compilation. |
| RegexRe2Tests.cs | Introduces the ported RE2-derived test cases and supporting data generation logic. |
src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/RegexRe2Tests.cs
Show resolved
Hide resolved
src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/RegexRe2Tests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/RegexRe2Tests.cs
Outdated
Show resolved
Hide resolved
stephentoub
reviewed
Oct 17, 2025
src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/RegexRe2Tests.cs
Show resolved
Hide resolved
Removed 57 test cases that were already covered by existing tests in PCRE, Rust, or core regex tests: - Basic patterns like "a", "a*", "a+", "a?" with simple inputs - Simple anchor tests "^$", "^", "$" that duplicate existing coverage - Trivial quantifier tests already well-tested elsewhere - Basic UTF-8 tests with single character patterns Retained 85 unique test cases that add value: - Complex patterns and edge cases - Word boundary tests with various scenarios - Multiline mode tests - Case-insensitive matching - Octal/hexadecimal escapes - Non-trivial quantifier combinations Co-authored-by: stephentoub <[email protected]>
Copilot finished work on behalf of
stephentoub
October 17, 2025 14:49
stephentoub
approved these changes
Oct 17, 2025
MihaZupan
approved these changes
Oct 17, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR ports functional regex tests from the RE2 test suite to improve .NET's regex test coverage, as requested in #120756.
Changes
Test Suite Additions
RegexRe2Tests.cs: New test file containing 85 unique test cases ported from RE2'sre2_test.ccandsearch_test.ccTest Categories Covered
The ported tests validate:
^,$) in single-line and multiline modes with non-trivial cases\b,\B) with ASCII and special characters\141, hexadecimal\x61, unicode\u0061)(?i)){n},{n,},{n,m})Compatibility Adjustments
Several RE2-specific patterns were excluded or adapted for .NET compatibility:
\Cpatterns: RE2's byte-matching construct is not supported in .NET\Q...\Epatterns: Quote meta syntax is not supported in .NET\x{...}escapes: Changed to .NET-compatible\x(2 digits) or\u(4 digits) formatRegexHelpers.IsNonBacktracking()checkLicense Attribution
THIRD-PARTY-NOTICES.TXT: Added RE2 BSD 3-Clause license to properly attribute the ported tests.csproj: AddedRegexRe2Tests.csto the compilationTesting
All 29,621 tests pass successfully, including the newly ported RE2 tests across all regex engines.
Fixes #120756
Original prompt
Fixes #61896
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.